<?php namespace Admin\Controller;
/*
 * 修改密码
 * */
	class UserController extends CommonController
	{
		public function ChangePwd()
		{
			if(IS_POST){
				$userdata = new \Common\Model\User;
				$data = $userdata->where("uid","=",$_SESSION["uid"])->first();
				//p($data);die;
				//p(md5($_POST["password"]));die;
				if($data["password"]!=md5($_POST["password"])){
					$this->error("原密码错误！");
				}
				if($_POST["newPassword"]!=$_POST["confirmPassword"]){
					$this->error("两次密码输入的不一致！");
				}
				if($data["password"]==md5($_POST["newPassword"])){
					$this->error("新密码和原密码不能一样！");
				}
				//$newpassword = 
				//修改数据
				$userdata->where("uid","=",$_SESSION["uid"])->update(array("password"=>md5($_POST["newPassword"])));
				//修改成功后删除session
				session_unset();
				session_destroy();
				//跳转到登录页面
				go("Login/index");
			}
			View::make();
		}
	}
	